package com.kuzufang.modules.main;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.kuzufang.R;
import com.kuzufang.base.BaseFragment;
import com.kuzufang.modules.mine.EditUserActivity;
import com.kuzufang.modules.mine.SettingActivity;

/**
 * Created by songyuanjin on 2017/9/27.
 */

public class NavigationFragment extends BaseFragment implements View.OnClickListener {
    private TextView mPublishTextView;
    private TextView mCollectTextView;
    private TextView mSeeTextView;
    private TextView mFeedBackTextView;
    private TextView mSettingTextView;
    private CardView mNavHeaderView;

    private onCloseDrawerLayoutListener mOnCloseDrawerLayoutListener;

    public interface onCloseDrawerLayoutListener {
        void onClose(MainActivity.OnDrawerCloseListener listener);

        void onCloseOnly();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_navigation, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mOnCloseDrawerLayoutListener = (onCloseDrawerLayoutListener) getActivity();

        mPublishTextView = (TextView) view.findViewById(R.id.tv_mine_publish);
        mCollectTextView = (TextView) view.findViewById(R.id.tv_mine_collect);
        mSeeTextView = (TextView) view.findViewById(R.id.tv_mine_see);
        mFeedBackTextView = (TextView) view.findViewById(R.id.tv_feedback);
        mSettingTextView = (TextView) view.findViewById(R.id.tv_setting);
        mNavHeaderView = (CardView) view.findViewById(R.id.nav_header_view);

        mPublishTextView.setOnClickListener(this);
        mCollectTextView.setOnClickListener(this);
        mSeeTextView.setOnClickListener(this);
        mFeedBackTextView.setOnClickListener(this);
        mSettingTextView.setOnClickListener(this);
        mNavHeaderView.setOnClickListener(this);

        mNavHeaderView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getContext(), EditUserActivity.class));
//                Intent intent = new Intent(getContext(), LoginActivity.class);
//                intent.putExtra("showToolBar", true);
//                startActivity(intent);
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_mine_publish:
                break;
            case R.id.tv_setting:
                startActivity(new Intent(getContext(), SettingActivity.class));
                break;
        }

        if (mOnCloseDrawerLayoutListener != null) {
            mOnCloseDrawerLayoutListener.onClose(new MainActivity.OnDrawerCloseListener() {
                @Override
                public void onDrawerClosed() {

                }
            });
        }
    }
}
